home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8193 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: shark.sb.grci.com!usenet
  2. From: "Howard S. Ostrowsky" <shermo@sb.grci.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Borland Addition
  5. Date: 15 Feb 1996 17:22:12 GMT
  6. Organization: GRC International, Inc.
  7. Message-ID: <4fvq44$ien@shark.sb.grci.com>
  8. References: <2d7cc$14c35.82@NEWS> <4ft9m5$fsr@netnews.upenn.edu>
  9. NNTP-Posting-Host: sherm.sb.grci.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.22 (Windows; I; 16bit)
  14.  
  15. modavis@ssc.sas.upenn.edu (Morris A. Davis) wrote:
  16. >Gooseman () wrote:
  17. >: I just saw an interesting bug in "Windows Developer" magazine (I think
  18. >: that's the title).
  19. >
  20. >: #include <iostream.h>
  21. >: int main()
  22. >: {
  23. >:   int i = 1;
  24. >:   int j = 1;
  25. >
  26. >:   if(i)
  27. >:     i = i + 4;
  28. >:     else
  29. >:     i = j + 4;
  30. >
  31. >:   cout << i;
  32. >: }
  33. >
  34. >: You would expect the output to be 5, but the result will be 9!  I
  35. >: tried this under 4.52 and 4.0 and both produced the same results.
  36. >
  37.  
  38. This may be a problem with the optimizer; if you compile with optimization
  39. turned off, the bug does not appear.  
  40.  
  41.                    Sherm Ostrowsky
  42.  
  43.